package com.woniuxy.yogaapp.service.imp;

import java.util.List;

import javax.annotation.Resource;
import com.woniuxy.yogaapp.pojo.Chat;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.woniuxy.yogaapp.mapper.ChatMapper;
import com.woniuxy.yogaapp.pojo.Coach;
import com.woniuxy.yogaapp.pojo.YogaClub;
import com.woniuxy.yogaapp.service.ChatService;
import com.woniuxy.yogaapp.util.TimeUtil;

import lombok.Data;

@Data
@Service
@Transactional
public class ChatServiceImp implements ChatService {
	@Resource
	private ChatMapper chatMapper;

	// 教练资格认证
	@Override
	public int coachToAdmin(Coach coach1) {
		coach1.getUid();// 用户id
		coach1.getCname();// 名字
		coach1.getCtel();// 电话
		coach1.getCidcard();// 身份证号
		coach1.getCgenre();// 流派
		String mes = "用户：" + coach1.getCname() + ",电话：" + coach1.getCtel() + ",身份证号：" + coach1.getCidcard() + ",请求申请"
				+ coach1.getCgenre() + "流派教练,请及时处理！";
		String time = TimeUtil.getNowDate();
		Chat chat = new Chat(0, coach1.getUid(), 1, mes, "未读", time, 6,"未处理");
		int row = chatMapper.addChat1(chat);
		return row;
	}

	// 场馆认证
	@Override
	public int yogaClubToAdmin(YogaClub yogaClub1) {
		yogaClub1.getYname();// 会馆名字
		yogaClub1.getLegalperson();// 负责人名字
		yogaClub1.getYtel();// 会馆电话
		yogaClub1.getYidcard();// 负责人身份证
		String mes = "负责人：" + yogaClub1.getLegalperson() + ",电话：" + yogaClub1.getYtel() + ",身份证："
				+ yogaClub1.getYidcard() + "场馆名：" + yogaClub1.getYname() + ",请求认证,请及时处理！";
		String time = TimeUtil.getNowDate();
		Chat chat = new Chat(0, yogaClub1.getUid(), 1, mes, "未读", time, 7,"未处理");
		int row = chatMapper.addChat1(chat);

		return row;

	}

	@Override
	public List<Chat> findAllCoachMes() {
		List<Chat> chat = chatMapper.findCoachChat();
		return chat;
	}

	@Override
	public List<Chat> findAllClubMes() {
		List<Chat> chat = chatMapper.findClubChat();
		return chat;
	}

	@Override
	public List<Chat> findReadyCoachMes() {
		List<Chat> chat = chatMapper.findReadyCoachChat();
		return chat;
	}

	@Override
	public List<Chat> findReadyClubMes() {
		List<Chat> chat = chatMapper.findReadyClubChat();
		return chat;
	}

}
